// 上传基础数据
$("#basisUpload").pluploadQueue({
	runtimes : "html5,flash,silverlight,html4",
	flash_swf_url : "/controls/plUpload/js/Moxie.swf",
	silverlight_xap_url : "/controls/plUpload/js/Moxie.xap",
	url : "/app/project!implExcelBasis",
	filters : {
		mime_types : [ {
			title : "上传Excel文档",
			extensions : "xls,xlsx"
		} ]
	},
	rename : true,// 重命名
	dragdrop : true,
	multiple_queues : true
});
// 上传详情数据
$("#detailUpload").pluploadQueue({
	runtimes : "html5,flash,silverlight,html4",
	flash_swf_url : "/controls/plUpload/js/Moxie.swf",
	silverlight_xap_url : "/controls/plUpload/js/Moxie.xap",
	url : "/app/project!implExcelDetail",
	filters : {
		mime_types : [ {
			title : "上传Excel文档",
			extensions : "xls,xlsx"
		} ]
	},
	rename : true,// 重命名
	dragdrop : true,
	multiple_queues : true
});
// 新版格式/上传转结数据
$("#swerveUpload").pluploadQueue({
	runtimes : "html5,flash,silverlight,html4",
	flash_swf_url : "/controls/plUpload/js/Moxie.swf",
	silverlight_xap_url : "/controls/plUpload/js/Moxie.xap",
	url : "/app/project!implExcelSwerve",
	filters : {
		mime_types : [ {
			title : "上传Excel文档",
			extensions : "xls,xlsx"
		} ]
	},
	rename : true,// 重命名
	dragdrop : true,
	multiple_queues : true
});
function toJson(str) {
	var json = eval('(' + str + ')');
	return json;
}
var basisUpload = $('#basisUpload').pluploadQueue();
basisUpload.bind('FileUploaded', function(up, file, res) {
	var result = toJson(res.response);
	if (result.state == "success") {
		alert("导入成功。");
	} else {
		alert("导入数据缺失，请认真检查导入的数据。");
	}
});
var detailUpload = $('#detailUpload').pluploadQueue();
detailUpload.bind('FileUploaded', function(up, file, res) {
	var result = toJson(res.response);
	if (result.state == "success") {
		alert("导入成功。");
	} else {
		alert("导入数据缺失，请认真检查导入的数据。");
	}
});
var swerveUpload = $('#swerveUpload').pluploadQueue();
swerveUpload.bind('FileUploaded', function(up, file, res) {
	var result = toJson(res.response);
	if (result.state == "success") {
		alert("导入成功。");
	} else {
		alert("导入数据缺失，请认真检查导入的数据。");
	}
});
$("[name='type']").change(function(){
	var v = $(this).val();
	switch (Number(v)) {
	case 1:
		$("#type1").show();
		$("#type2").hide();
		$("#type3").hide();
		break;
	case 2:
		$("#type1").hide();
		$("#type2").show();
		$("#type3").hide();
		break;
	case 3:
		$("#type1").hide();
		$("#type2").hide();
		$("#type3").show();
		break;
	}
});

//*****************************************************拆分EXCEL
var upload = new plupload.Uploader({
	browse_button : 'separateExcel',
	runtimes : "html5,flash,silverlight,html4",
	flash_swf_url : "js/plUpload/js/Moxie.swf",
	silverlight_xap_url : "js/plUpload/js/Moxie.xap",
	url : "/app/excel!separateExcel",
	filters : {
		mime_types : [ {
			title : "上传Excel文档",
			extensions : "xls,xlsx"
		} ]
	},
	rename : false,// 重命名
	dragdrop : true,
	multiple_queues : true,
	multi_selection : false
});
upload.init();
upload.bind('FilesAdded', function(up, file, res) {
	upload.start();
});
upload.bind('FileUploaded', function(up, file, res) {
	var result = toJson(res.response);
	if (result.state == "success") {
		alert("导入成功。");
	} else {
		alert("导入数据缺失，请认真检查导入的数据。");
	}
});